#利用map和reduce编写一个str2float函数，把字符串'123.456'转换成浮点数123.456

from functools import reduce

def str2float(s):
 tmp=list(map(_map,s))
 _big=tmp[:tmp.index(-1)]
 _small=tmp[tmp.index(-1)+1:]
 _small.reverse()
 #return _small
 return reduce(_reduce_big, _big) + reduce(_reduce_small, _small) / 10


def _map(x):
 return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'.':-1}[x]

def _reduce_big(x, y):
 return x*10 +y
def _reduce_small(x, y):
 return x/10 + y

print('str2float(\'28371810.239372\') =', str2float('28371810.239372'))
